package com.ita.dao.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.ita.dao.IBookDaoITA;
import com.ita.vo.Book;
@Repository(value="bookDaoITA")
public class BookDaoITAImpl implements IBookDaoITA {

	private static List<Book> books=new ArrayList<Book>();
	static{
		books.add(new Book("1","html","李明",90));
		books.add(new Book("2","css","李明",120));
		books.add(new Book("3","javasrcipt","李明",130));
		books.add(new Book("4","javaweb","李明",100));
	}
	public BookDaoITAImpl(){
		
	}
	public static BookDaoITAImpl getInstance(){
		return new BookDaoITAImpl();
	}
	
	
	@Override
	public Book persist(Book book) {
		Book book1=new Book("5","javaweb","李明",150);
		return book1;
	}

	@Override
	public Book update(Book book) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Book> queryAll() {
		return books;
	}

	@Override
	public Book remove(String bookid) {
		Iterator<Book> it=books.iterator();
		Book book=null;
		while(it.hasNext()){
			Book b=it.next();
			if(b.getBookid().equals(bookid)){
				book=b;
				it.remove();
				break;
			}
		}
		return book;
	}

	@Override
	public Book remove(Book book) {
		// TODO Auto-generated method stub
		return null;
	}

}
